<template>
	<view class="physical-appoint-detail">
		<UserDate @changeUser='onChangeUser' @changeDate='onChangeDate'/>
		<view class="physical-appoint-detail-main">
			<view v-for="(item,index) in listData" :key="index" class="card">
				<view class="title u-border-bottom">
					<view class="left">
						<text class="iconfont icon-baogaoguanli_huaban1"></text>
						<text>{{item.healthNo||''}}</text>
					</view>
					<view class="right">
					</view>
				</view>
				<view class="main flexR">
					<view class="left">
						<view class="row" v-if="item.name"><text>姓名：</text>{{item.name||''}} </view>
						<view class="row" v-if="item.companyName"><text>单位：</text>{{item.companyName||''}} </view>
						<view class="row"><text>体检分类：</text>{{item.healthTypeName||''}} </view>
						<view class="row"><text>体检编号：</text>{{item.healthNo||''}} </view>
						<view class="row"><text>联系电话：</text>{{item.telephone||''}} </view>
						<view class="row"><text>体检时间：</text>{{item.appointmentDate||''}} </view>
						<view class="row"><text>体检状态：</text>{{item.healthStatus|transStatus}} </view>
					</view>
					<view v-if="type==3||type==4" class="right" @click="toPage(item)">
						<u-icon name="arrow-right" color="#B5B5B5"></u-icon>
					</view>
				</view>
				<view class="div-cut"></view>
			</view>
			<u-empty text='暂无预约信息' mode="list" v-if="showEm&&listData.length===0"></u-empty>
		</view>
		<Load :load="load" />
	</view>
</template>

<script>
	import Load from '@/components/Load/index.vue'
	// import Search from '@/components/Search/index.vue'
	import UserDate from '@/components/UserInfo/user-date.vue'
	import { mapGetters } from 'vuex'
	import { getHealthRecord } from '@/api/physical.js'
	import {defaultDate} from '@/common/js/default-date.js'
	export default {
		components:{ Load, UserDate },
		data() {
			return {
				load:false,
				idCard:'',
				showEm:false,
				type:2,//2预约详情 3 报告进度 4 报告列表
				listData:[],
				queryDate:''
			}
		},
		computed:{
			...mapGetters(['userInfo'])
		},
		async onLoad(op) {
			if(op.type){
				this.type = op.type
				if(op.type==='3'){
					uni.setNavigationBarTitle({
						title: '报告进度'
					});
				}else if(op.type==='4'){
					uni.setNavigationBarTitle({
						title: '报告列表'
					});
				}
			}
			this.queryDate = defaultDate
			await this.$onLaunched
			this.initData()
		},
		filters:{
			transStatus(val){
				if(val==='0'){
					return '未体检'
				}else if(val==='1'){
					return '到检查'
				}else if(val==='2'){
					return '体检中'
				}else{
					return ''
				}
			}
		},
		methods: {
			initData(){
				this.load = true
				if(!this.userInfo.patId){
					uni.navigateTo({
						// url:'/pages/Login/index'
						url:'/pages/Login/addPatient'
					})
					return
				}
				let params = {
					...this.queryDate,
					patientId: this.userInfo.patId,
					status:this.type - 1
				}
				getHealthRecord(params).then(data => {
					this.load = false
					this.listData = data||[]
					this.showEm = true
				}).catch(e => {
					this.load = false
					this.listData = []
					this.showEm = true
				})
			},
			toPage(item){
				if(this.type=='3'){
					uni.navigateTo({
						url:'/physical/PhysicalServe/progress?healthNo=' + item.healthNo
					})
				}else if(this.type=='4'){
					uni.navigateTo({
						url:'/physical/PhysicalServe/report?healthNo=' + item.healthNo
					})
				}
			},
			onChangeUser(val){
				this.initData()
			},
			onChangeDate(val){
				this.queryDate = val
				this.initData()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.physical-appoint-detail{
		height: 100%;
		background-color: #fff;
		&-main{
			height: calc(100vh - 100rpx);
			overflow: scroll;
		}
	}
</style>
